package cn.gemframe.thread;

import cn.gemframe.utils.GemJsonUtils;

public class GemFrameThreadVariable {

	private static final ThreadLocal<Object> LOCAL = new ThreadLocal<Object>();

	public static void set(Object obj) {
		LOCAL.set(obj);
	}

	public static Object get() {
		return LOCAL.get();
	}

	public static <T> T getClass(Class<T> clazz) {
		Object object = LOCAL.get();
		if (object == null)return null;
		return GemJsonUtils.jsonToClass(GemJsonUtils.objectToJson(object), clazz);
	}
}
